# c:收盘；h：最高价;l:最低价;o:开盘;t:日期
# https://api-q.fx678img.com/histories.php?symbol=LMCI&limit=100&resolution=D&codeType=5210&st=0.8122843826306168
# https://quote.fx678.com/symbol/LMCI?_da0.07986568337345568

import time

c = [
    6515, 6500, 6545.5, 6429, 6297, 6236, 6193, 6140, 6015, 6093.5, 6056, 6039,
    5969, 5943, 5937, 5889, 5911, 5895, 5810, 5802, 5797, 5742, 5739, 5779.5,
    5753, 5904, 5767, 5717, 5659, 5525, 5508.5, 5518.5, 5484, 5380, 5380,
    5295.5, 5369, 5305, 5390, 5445.5, 5353, 5345.5, 5185.5, 5213, 5212, 5229,
    5280.5, 5280.5, 5218.5, 5176, 5129, 5106, 5183, 5246, 5208.5, 5186, 5188,
    5139, 5108.5, 5026.5, 5174, 5210, 5116.5, 5111.5, 5188.5, 5032, 5022.5,
    5024, 4904.5, 4842, 4881.5, 4804.5, 4930, 4756.5, 4801.5, 4808.5, 4874,
    4830.5, 4618.5, 4766.5, 4825, 4725, 5138.5, 5277.5, 5457.5, 5459, 5525,
    5566, 5522, 5646, 5674, 5698, 5676, 5724.5, 5606, 5666, 5670.5, 5696, 5698,
    5770
]

# print(c)

h = [
    6550, 6532.5, 6633, 6429.5, 6360, 6248, 6195, 6143, 6085, 6120, 6094, 6055,
    5993, 6006, 5943.5, 5948, 5920, 5902, 5899, 5862.5, 5804, 5836, 5774, 5842,
    5928, 5913.5, 5780, 5719, 5698, 5546, 5552, 5532, 5488, 5387.5, 5380, 5368,
    5404.5, 5390, 5464, 5455, 5377.5, 5347, 5272, 5235.5, 5272.5, 5291.5, 5370,
    5295, 5242, 5185, 5134.5, 5170, 5294.5, 5280, 5252, 5269, 5190, 5210, 5137,
    5182, 5248, 5237.5, 5150, 5184, 5200, 5070, 5065, 5114, 4927, 4936.5, 4936,
    4912.5, 4971, 4803.5, 4866.5, 4854.5, 4890.5, 4929.5, 4676, 4938.5, 4841,
    5191, 5365, 5436.5, 5589, 5485, 5612, 5653.5, 5583, 5685, 5731.5, 5730,
    5780.5, 5733.5, 5653.5, 5681, 5696.5, 5728, 5716.5, 5788.5
]

l = [
    6515, 6431, 6439.5, 6253.5, 6246, 6168, 6076, 6031, 5987, 6047.5, 5995,
    5971, 5924.5, 5923, 5852, 5858, 5823, 5807, 5787, 5751.5, 5713, 5698,
    5665.5, 5688, 5738, 5776.5, 5676, 5618, 5507.5, 5448.5, 5487, 5450, 5385,
    5319.5, 5294, 5247, 5333, 5261.5, 5380, 5328, 5322, 5205, 5176, 5146, 5189,
    5220, 5244.5, 5188, 5146.5, 5117, 5060, 5077, 5177, 5197, 5170, 5153.5,
    5105, 5084, 4973.5, 4953, 5161, 5165, 5092, 5070, 5127, 4984, 4964, 4937,
    4841, 4833.5, 4760, 4769, 4800, 4739.5, 4768.5, 4767, 4745, 4643.5, 4461,
    4613, 4371, 4720, 5127, 5182.5, 5319.5, 5376.5, 5513.5, 5548.5, 5433,
    5592.5, 5655, 5667.5, 5622.5, 5577, 5533, 5574.5, 5623.5, 5673, 5671.5,
    5684
]

o = [
    6540, 6500, 6455, 6305, 6247, 6180, 6158, 6040.5, 6082, 6090, 6038, 5980,
    5931, 5939.5, 5873, 5902, 5904, 5807, 5809, 5775.5, 5741, 5772, 5774, 5720,
    5902, 5780, 5729, 5660, 5510, 5498.5, 5537.5, 5472, 5400, 5350, 5303, 5345,
    5337.5, 5381, 5444, 5343.5, 5374, 5205, 5235, 5223, 5199, 5266, 5309, 5188,
    5177, 5140, 5085, 5167, 5278, 5200, 5180.5, 5200, 5144, 5105, 5070, 5155,
    5197.5, 5165, 5101.5, 5175, 5140, 5041, 4995, 4941, 4844.5, 4880, 4799.5,
    4898, 4800, 4766, 4832, 4854.5, 4849, 4701.5, 4675, 4741, 4780, 5156, 5335,
    5401, 5396, 5463.5, 5591, 5563, 5535, 5679.5, 5703, 5705, 5742, 5579, 5651,
    5665, 5670, 5710, 5712, 5743.5
]

t = [
    1594742400, 1594656000, 1594569600, 1594310400, 1594224000, 1594137600,
    1594051200, 1593964800, 1593705600, 1593619200, 1593532800, 1593446400,
    1593360000, 1593100800, 1593014400, 1592928000, 1592841600, 1592755200,
    1592496000, 1592409600, 1592323200, 1592236800, 1592150400, 1591891200,
    1591804800, 1591718400, 1591632000, 1591545600, 1591286400, 1591200000,
    1591113600, 1591027200, 1590940800, 1590681600, 1590595200, 1590508800,
    1590422400, 1590076800, 1589990400, 1589904000, 1589817600, 1589731200,
    1589472000, 1589385600, 1589299200, 1589212800, 1589126400, 1588780800,
    1588694400, 1588608000, 1588521600, 1588262400, 1588176000, 1588089600,
    1588003200, 1587916800, 1587657600, 1587571200, 1587484800, 1587398400,
    1587312000, 1587052800, 1586966400, 1586880000, 1586793600, 1586361600,
    1586275200, 1586188800, 1586102400, 1585843200, 1585756800, 1585670400,
    1585584000, 1585497600, 1585238400, 1585152000, 1585065600, 1584979200,
    1584892800, 1584633600, 1584547200, 1584460800, 1584374400, 1584288000,
    1584028800, 1583942400, 1583856000, 1583769600, 1583683200, 1583424000,
    1583337600, 1583251200, 1583164800, 1583078400, 1582819200, 1582732800,
    1582646400, 1582560000, 1582473600, 1582214400
]

# t0 = 'INSERT INTO "WB_TBL_DD_LME_PRICE"("ID", "VARIETY_ID", "M3_BUY", "M27_BUY", "M27_SELL", "M15_BUY", "M15_SELL", "M3_SELL", "CASH_BUY", "CASH_SELL", "USING_FLAG", "GROUP_ID", "ORGAN_ID", "ORGAN_LEVEL_CODE", "DELETE_FLAG", "CREATE_USER", "CREATE_DATE", "UPDATE_USER", "UPDATE_DATE", "VERSION_NUM", "TRADE_DATE", "CONTRACT_ID", "DATA_SOURCE", "OPEN_PRICE", "CLOSE_PRICE", "MAX_PRICE", "MIN_PRICE", "SETTLEMENT_PRICE") VALUES (WB_SEQ_DD_LME_PRICE.nextval'
t1 = ", 'Cu', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '1', NULL, NULL, NULL, '0', '获取用户信息为空', SYSDATE, '获取用户信息为空', SYSDATE, '1', "
t2 = " '0');"

t0 = 'INSERT INTO `price`(`id`, `close`, `highest`, `lowest`, `open`, `trade_date`) VALUES ('
# t1 = ');'

if __name__ == "__main__":
    r = ''
    for i in range(100):

        p3 = h[i]
        p4 = l[i]
        p2 = c[i]
        p1 = o[i]

        ts = t[i]
        dt = time.strftime("%Y-%m-%d", time.localtime(ts))

        # r += t0 + t1 + "TO_DATE('" + dt + "', 'YYYY-MM-DD'), '8', '0', " + "'" + str(
        #     p1) + "', " + "'" + str(p2) + "', " + "'" + str(
        #         p3) + "', " + "'" + str(p4) + "', " + t2 + "\n"

        r += t0 + str(i + 1) + ',' + str(p2) + ',' + str(p3) + ',' + str(
            p4) + ',' + str(p1) + ',\'' + dt + '\');\n'

    print(r)

    # str(i +1) +
